export default {
    inserted (el, binding, vNode) {
        const div = $('<div />');
        $(div).css({
            fontSize: '12px',
            cursor: 'pointer',
            position: 'absolute',
            bottom: '-24px',
            right: '0',
            width: '60px',
            margin: '0 0 0 auto',
            background: 'rgb(242, 242, 242)',
            padding: '5px',
            borderRadius: '0 0 10px 10px',
            textAlign: 'center',
            zIndex: 3,
        });
        $(div).html('收起');
        $(div).addClass('my-contraction');
        if (binding.value && binding.value.close) {
            $(el).addClass('my-header_hidden');
            $(div).html('展开');
        }
        $(el).parent().append(div);
        let style = {
            position: 'relative',
            marginBottom: '25px',
        };
        if (binding.value && binding.value.noMarginBottom) {
            delete style.marginBottom;
        }
        $($(el).parent()).css(style);
        $(div).off('click').on('click', e => {
            let check = $(el).hasClass('my-header_hidden');
            if (check) {
                $(el).removeClass('my-header_hidden');
                $(e.target).html('收起');
            } else {
                $(el).addClass('my-header_hidden');
                $(e.target).html('展开')
            }
            binding.value && binding.value.click && binding.value.click(check);
        });
    },
};
